package com.evaluation.kexingcp.psycho.evaluation.sys.sms

import com.evaluation.kexingcp.common.core.util.R
import com.evaluation.kexingcp.common.security.annotation.Inner
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController


@RestController
@RequestMapping("/sendRegisterSms")
open class SmsController(private val smsService: SmsService) {

    @PostMapping("/{mobile}")
    @Inner(false)
    open fun sendMobile(@PathVariable mobile: String) : R<String> {
        return smsService.sendRegisterSms(mobile).fold(
            ifLeft = { err ->
                R.failed(err.message)
            },
            ifRight = {
                R.ok(null, "发送成功")
            }
        )
    }


    @PostMapping("/email/{email}")
    @Inner(false)
    open fun sendEmail(@PathVariable email: String) : R<String> {
        return smsService.sendRegisterEmail(email,"测试组织", "测试用户","xxx.sxks.cn", null).fold(
            ifLeft = { err ->
                R.failed(err.message)
            },
            ifRight = {
                R.ok(null, "发送成功")
            }
        )
    }
}